<?php

namespace app\repository\dao\api;

use support\Db;

class PosDao
{
    public function getList(array &$data): array
    {
        $fields = ['id', 'hq_code', 'market_orgz_id', 'code',
                   'pos_status', 'uuid', 'orgz_id', 'checked_at',
                   'login_at', 'custom_code', 'pos_version', 'pos_type'
        ];
        $query = Db::table('pos')
            ->where('pos_status', $data['type']);

        $total = $query->count();
        $list = $query->offset($data['start'])
            ->limit($data['length'])
            ->orderBy('id', 'DESC')
            ->select($fields)
            ->get()->toArray();
        return ['total' => $total, 'list' => $list];
    }
}